<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>摊位申请信息</title>
<%@ include file="../inc.jsp"%>

<style type="text/css">
table.gridtable {
	font-family: verdana, arial, sans-serif;
	font-size: 11px;
	color: #333333;
	border-width: 1px;
	border-color: #666666;
	border-collapse: collapse;
}

table.gridtable th {
	border-width: 1px;
	padding: 10px;
	border-style: solid;
	border-color: #666666;
	background-color: #dedede;
	text-align:center;
}

table.gridtable td {
	border-width: 1px;
	padding: 10px;
	border-style: solid;
	border-color: #666666;
	background-color: #ffffff;
}

.imgTd{
	text-align:center;
}
</style>
</head>

<body class="easyui-layout">
<div style="padding: 30px">
		<form id="formModule" method="post" enctype="multipart/form-data"
			autocomplete="off">
			<input id="id" type="hidden" name="id"
				value="${selectId}">
			<table cellpadding="0" border="0" width="100%" class="gridtable">
				<tr>
					<th>支付宝收款二维码</th>
					<th>微信收款二维码</th>
				</tr>
				<tr>
					<td class="imgTd"><img alt="请上传" id="zhbQrCode" src="${baseUrl}/images/885.png" width="300px" height="300px"/></td>
					<td class="imgTd"><img alt="请上传" id="wxQrCode" src="${baseUrl}/images/885.png" width="300px" height="300px"/></td>
				</tr>
				<tr>
					<td><input type="file" id="ali_pay" class="textbox" style="width:250px;"
						name="ali_pay"></input></td>
					<td><input type="file" id="tx_pay" class="textbox" style="width:250px;"
						name="tx_pay"></input></td>
				</tr>
				<tr>
					<td colspan="2" class="imgTd">
						<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="doSave()" >保存</a>
					</td>
				</tr>
			</table>
		</form>
	</div>
	

	
	

</body>
<script type="text/javascript">
      $(document).ready(function(){
    	  loadInfo();
      })
      function loadInfo(){

    	   $.ajax({
		       async: true, 
		       type: "POST", 
		       url : '${baseUrl}/admin/qrCode/list',
		       cache:false,
		       dataType : 'json', 
		       success : function(data) { 
		    	   console.log('data',data)
		    	   if(data && data.length > 0){
		    		   data.forEach(function(item){
		    			   if(item.code_type == 1){
		    				   $('#zhbQrCode').attr('src','${sourceUrl}/'+item.code_url)
		    			   }
		    			   if(item.code_type == 2){
		    				   $('#wxQrCode').attr('src','${sourceUrl}/'+item.code_url)
		    			   }
		    		   })
		    	   }
		       } 
		   });
      }
   
    	function doSave(){
    		//根据ID获得页面当中的form表单元素
    		var form = document.querySelector("#formModule");
    		//将获得的表单元素作为参数，对formData进行初始化
    		var formdata = new FormData(form);
    		//通过get方法获得name为advName元素的value值
			var url = '${baseUrl}/admin/qrCode/save'

    		var tip = ''
    		if(!$('#ali_pay').val()){
    			tip = '支付宝收款码不能为空！'
    		} else if(!$('#tx_pay').val()){
    			tip = '微信收款码不能为空！'
    		}
    		if(tip){
    			$.messager.alert('提示',tip,'error');
    			return false;
    		}
    		

   			$.ajax({
   				async : false,
   				url : url,
   				type : "post",
   				data : formdata,
   				cache : false,
   				contentType : false,
   				processData : false,
   				dataType : 'json',
   				success : function(data) {
   					if (data.success != 0) {
   						top.Ext.Msg.alert("提示", data.msg);
   					} else {
   						$.messager.alert('提示','操作成功！','info')
   						loadInfo()
   					}
   				}
   			});


    	}
	</script>
<style type="text/css">
.showBtn {
	display: inline;
}
</style>
</html>
